home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / GCC 1.37.1r14 / usr / gcc-1.37.1r14 / (gcc-1.37.π) / fopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-01  |  727 b   |  36 lines  |  [TEXT/KAHL]

  1. /* A new and improved fopen that makes MPW text files. */
  2.  
  3. /* This should only be compiled and linked under MPW - note that config.h
  4.    must *not* be included, or "mpw_fopen" will call itself! */
  5.  
  6. #ifdef MPW
  7.  
  8. #include <StdIO.h>
  9. #include <Files.h>
  10.  
  11. FILE *
  12. mpw_fopen(name, mode)
  13. char *name, *mode;
  14. {
  15.     char *pname = (char *) malloc(strlen(name) + 2);
  16.     OSErr e;
  17.     FILE *fp;
  18.     struct FInfo fi;
  19.  
  20.     pname[0] = strlen(name);
  21.     strcpy(pname+1, name);
  22.     
  23.     fp = fopen(name, mode);
  24.     
  25.     e = GetFInfo(pname, 0, &fi);
  26.     /* should do spiffier error handling */
  27.     if (e != 0) printf("%d\n", e);
  28.     fi.fdType = (OSType) 'TEXT';
  29.     fi.fdCreator = (OSType) 'MPS ';
  30.     e = SetFInfo(pname, 0, &fi);
  31.     if (e != 0) printf("%d\n", e);
  32.     return fp;
  33. }
  34.  
  35. #endif /* MPW */
  36.